<template>
  <div style="height: 100%;">
    <el-menu
        :default-active="this.$store.state.menus.editableTabsValue"
        class="el-menu-vertical-demo"
        background-color=""
        text-color=""
        active-text-color=""
    >
      <router-link to="/index">
        <el-menu-item index="Index" >
          <template slot="title">
            <i class="el-icon-s-home"></i>
            <span slot="title">首页</span>
          </template>
        </el-menu-item>
      </router-link>
      <el-submenu :index="menu.permCode" v-for="menu in menuList">
        <template slot="title">
          <i :class="menu.requestPath"></i>
          <span>&nbsp;&nbsp;&nbsp;{{menu.name}}&nbsp;&nbsp;&nbsp;</span>
        </template>
        <router-link :to="'/'+item.pagePath" v-for="item in menu.children">
          <el-menu-item :index="item.pagePath" @click="addTab(item)">
            <template slot="title">
              <span slot="title">{{item.name}}</span>
            </template>
          </el-menu-item>
        </router-link>
      </el-submenu>
    </el-menu>
  </div>
</template>

<script>
export default {
  name: "SideMenu",
  data(){
    return{
    }
  },
  computed:{
    menuList:{
      get(){
        return this.$store.state.menus.menuList;
      }
    }
  },
  methods:{
    addTab(item){
      this.$store.commit("addTab",item)
    }
  }
}
</script>

<style scoped>
.el-menu-vertical-demo {
  height: 100%;
}
</style>